package com.hjy.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hjy.demo.mapper.RoleMapper;
import com.hjy.demo.pojo.Role;
import com.hjy.demo.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {
    @Resource
    private RoleMapper roleMapper;


    @Override
    public List<Role> findAll() {
        return roleMapper.selectList(null);
    }

    @Override
    public IPage<Role> RolePage(Page<Role> page, Wrapper<Role> queryWrapper) {
        return roleMapper.selectPage(page,queryWrapper);
    }

    @Override
    public int addRole(Role role) {
        return roleMapper.insert(role);
    }

    @Override
    public int deleteRole(Long roleId) {
        return roleMapper.deleteById(roleId);
    }

    @Override
    public int updateRole(Role role) {
        return roleMapper.updateById(role);
    }

    @Override
    public Role getRole(Long roleId) {
        return roleMapper.selectById(roleId);
    }
}
